/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package spidercore;

/**
 *
 * @author Lone_Wolf
 */
public class TorrificTorrent {

    private String lien = "";
    private String nom = "";
    private double taille = 0;
    private TorrificTorrentStatus status;
    private String dateAdded;

    public TorrificTorrent(String s) {
        //parse URL link
        lien = s.substring(s.indexOf("<a href"), s.indexOf(">", s.indexOf("<a href")));
        lien = lien.substring(lien.indexOf("/"), lien.length() - 2);

        //parse torrent name
        nom = s.substring(s.indexOf("<span class=\"black\">"), s.indexOf("</span>"));
        nom = nom.substring(20);

        //parse torrent size
        String tempTaille = s.substring(s.indexOf("width=\"90px\""));
        tempTaille = tempTaille.substring(tempTaille.indexOf(">") + 1, tempTaille.indexOf("<"));
        taille = Double.parseDouble(tempTaille);
        
        //parse torrent status
        if (s.contains("available")){
            status = status.AVAILABLE;
        } else if (s.contains("removed")){
            status = status.REMOVED;
        } else if (s.contains("queuing")){
            status = status.QUEUING;
        }
        
        //parse date added
        String tempDate = s.substring(s.indexOf("width=\"120px\""));
        tempDate = tempDate.substring(tempDate.indexOf(">") + 1, tempDate.indexOf("<"));
        dateAdded = tempDate;
    }
}
